<?php
require('common.php');

$instance = sql_row1("SELECT * FROM Instances WHERE User='$user' AND Domain='$domain' AND Line_Number='$line'");
//die(var_dump($instance));
$definition_id = $instance['Var1'];
$def = sql_row1("SELECT * FROM Definitions WHERE ID='$definition_id'");
//die(var_dump($def));

// if the form was submitted, store the values
if (!empty($G['save']))
{
	// store it in the instance
	$field_name = $G['field_name'];
	$field_caption = $G['field_caption'];
	
	// store this name in the definition
	sql_exec("UPDATE Instances SET Var1_Text='$field_name', Var2_Text='$field_caption' WHERE User='$user' AND Domain='$domain' AND Line_Number='$line'  ");
	update($user, $domain, $line);
	header("Location: edit_page.php?domain=$domain");
}

html_header("Edit a Form's Field");
?>

<body>

<div id="container">

<?php header_div(); ?>

<div id="body">

<h4>edit a form field</h4>

<form action="form_input.php" method="get">
<p>Field Name: <input name="field_name" value="<?php echo $instance['Var1_Text']; ?>" /></p>
<p>Field Caption: <input name="field_caption" value="<?php echo $instance['Var2_Text']; ?>" /></p>
<input type="hidden" name="domain" value="<?php echo $domain; ?>" />
<input type="hidden" name="line" value="<?php echo $line; ?>" />


<p><input type="submit" name="save" value="save" /></p>
</form>

<p>
<form action="delete_instance.php" method="get">
<input type="hidden" name="domain" value="<?php echo $domain; ?>" />
<input type="hidden" name="line" value="<?php echo $line; ?>" />
<input type="submit" value="delete">
</form>
</p>


<?php echo footer(); ?>

</div>

</div>
</body>
</html>
